package com.huawei.codearts.model;


import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Order {

    private Integer id;
    private String number;
    private String sort;
    private Integer memberId;
    private String memberName;
    private BigDecimal price;
    private Long createTime;
    private String createTimeFormat;

    public Order() {}

    public Order(Integer id, String number, String sort, Integer memberId, String memberName, BigDecimal price, Long createTime) {
        this.id = id;
        this.number = number;
        this.sort = sort;
        this.memberId = memberId;
        this.memberName = memberName;
        this.price = price;
        this.createTime = createTime;
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getSort() {
        return this.sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public Integer getMemberId() {
        return this.memberId;
    }

    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

    public String getMemberName() {
        return this.memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public String getCreateTimeFormat() {
        return createTimeFormat;
    }

    public void setCreateTimeFormat(String createTimeFormat) {
        this.createTimeFormat = createTimeFormat;
    }

    @Override
    public String toString() {
        return "OrderRepository{" +
                "id=" + id +
                ", number='" + number + '\'' +
                ", sort='" + sort + '\'' +
                ", memberId='" + memberId + '\'' +
                ", memberName='" + memberName + '\'' +
                ", price='" + price + '\'' +
                ", createTime='" + createTime + '\'' +
                '}';
    }

    public static Order fromResultSet(ResultSet rs) throws SQLException {
        return new Order(
                rs.getInt("id"),
                rs.getString("number"),
                rs.getString("sort"),
                rs.getInt("member_id"),
                rs.getString("membername"),
                rs.getBigDecimal("price"),
                rs.getLong("createtime")
        );
    }

}
